#include "playStatusParam.h"
#include "jsonUtils.h"

PlayStatusParam::PlayStatusParam() : duration(0), position(0), volume(0)
{

}

PlayStatusParam::PlayStatusParam(const int64_t& movieId, const int& scene, const int& duration, const int& position, const int& volume)
	: SceneParam(movieId, scene), duration(duration), position(position), volume(volume)
{

}

JsonDoc& PlayStatusParam::jsonSerialize()
{
	JsonDoc& doc = SceneParam::jsonSerialize();
	JsonDoc::AllocatorType& allocator = doc.GetAllocator();
	doJsonSerialize(doc, allocator);
	return doc;
}

JsonValue& PlayStatusParam::jsonSerialize(JsonValue& v, JsonDoc::AllocatorType& allocator)
{
	SceneParam::jsonSerialize(v,allocator);
	doJsonSerialize(v, allocator);
	return v;
}

JsonDoc& PlayStatusParam::jsonDeserialize(const String& json)
{
	JsonDoc& doc = SceneParam::jsonDeserialize(json);
	doJsonDeserialize(doc);
	return doc;
}

const JsonValue& PlayStatusParam::jsonDeserialize(const JsonValue& v)
{
	SceneParam::jsonDeserialize(v);
	doJsonDeserialize(v);
	return v;
}

void PlayStatusParam::doJsonSerialize(JsonValue& v, JsonDoc::AllocatorType& allocator)
{
	v.AddMember(L"duration", duration, allocator);
	v.AddMember(L"position", position, allocator);
	v.AddMember(L"volume", volume, allocator);
}

void PlayStatusParam::doJsonDeserialize(const JsonValue& v)
{
	JsonUtils::loadInt(v, L"duration", duration);
	JsonUtils::loadInt(v, L"position", position);
	JsonUtils::loadInt(v, L"volume", volume);
}
